#pragma once



#ifndef LIGHTER_H
#define LIGHTER_H



#include "Color.h"
#include "Coordinates.h"
#include "Polygon.h"
#include "psLightSource.h"
#include "World.h"
#include "Drawer.h"
#include "Light.h"
#include <cmath>
#include "BackgroundImage.h"
#include "PngWrapper.h"

namespace HW2
{
	
	Color shadeOfGrey(int k);

	typedef enum {FLAT, GUARDED,PHONG,TEXTURE_MARBEL,TEXTURE_WOOD,TEXTURE_RUST,TEXTURE_ARMY,TEXTURE_EARTH,TEXTURE_REPTILE_SKIN,TEXTURE_MIRROR} ShadingType;
	
	//struct Lighter-------------------------------------------------------------;
	struct Lighter{
		
		psLightSource sources[8];
		Color ambientLight;
		Polygon currentPolygon;
		Coordinates viewVector;
		ShadingType shadingType;
		LightType type;

		bool shadows;
		double k_ambient;
		double k_specular;
		double k_diffusive;
		double n_shininess;
		bool viewSpace;
		bool isSet;
		bool textureIsSet;
		int sPtr;
		int pixelSize;
		bool fogActivated;
		Color fogColor;
		bool baseActivated;

		std::vector<std::string> objectNames;
		std::vector<ShadingType> objectShading;
		std::vector<std::string> objectShadingNames;



	Lighter();

	
	void setAmbient(double r  ,double g , double b);

	void restart();

	Color getLightning(Coordinates &c,Coordinates& orig);

	void transformLightSources();

	void setViewVector(double x ,double y,double z);

	Color ambient(Coordinates &c);
	Coordinates pointToCamera(Coordinates c);

	void calcDirectLight(int i);
	void calcPointLight(int i);
	int  sign(double c);

	Color CalcFog(Coordinates& c);
		
	static Lighter& get(){
		static Lighter l;
		return l;
		}

	HW2::BackgroundImage* backImage;
	void copyPolygon(Polygon& p);


	double cosTeta(Coordinates& p1,Coordinates& p2);


	Color interpulateColor(Coordinates& c);

	Color normalIntrpulateColor(Coordinates& c,Coordinates& cOrig);

	Color normalIntrpulateColorOriginal(Coordinates& c);

	Coordinates calcReflectionVec(Coordinates& normal, Coordinates& LightVec,double teta);

	double cosAlpha(Coordinates& normal, Coordinates& LightVec,double teta,Coordinates c);

	Color material(Coordinates c);

	float turbulence(const Coordinates& c ,float scale,float pixSiz);

	};

	//-------------------------------------------------------------------------------------------------
	// x, y, z
	Color getLightedColor(Coordinates c, Coordinates orig, Polygon &p);

	Color interpulate(Color c1,Color c2,Color c3);

	
}
#endif /* LIGHTER_H */